package com.example.flutter_app

import android.content.Context
import android.os.Bundle
import android.widget.Toast
import io.flutter.embedding.android.FlutterActivity
import io.flutter.embedding.engine.FlutterEngine
import io.flutter.plugin.common.BinaryMessenger
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugins.GeneratedPluginRegistrant
import java.nio.ByteBuffer
import kotlin.contracts.contract

class MainActivity: FlutterActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        MethodChannelDemo(this, flutterEngine!!.dartExecutor.binaryMessenger)
    }
}

class MethodChannelDemo(val context: Context, messenger: BinaryMessenger) : MethodChannel.MethodCallHandler{

    private var channel: MethodChannel = MethodChannel(messenger, "bridge")

    init {
        channel.setMethodCallHandler(this)
    }

    override fun onMethodCall(call: MethodCall, result: MethodChannel.Result) {
        when(call.method){
            "getInfo" -> {
                result.success(android.os.Build.BRAND +"-"+ android.os.Build.MODEL)
            }
        }
    }
}
